# 定义二分查找
def binary_search(sorted_sequence, target):
    left = 0
    right = len(sorted_sequence) - 1
    while left <= right:
        midpoint = (left+right) // 2
        current_item = sorted_sequence[midpoint]
        if current_item == target:
            return "查找成功, 元素{}的下标为{}".format(target, midpoint)
        elif target < current_item:
            right = midpoint - 1
        else:
            left = midpoint + 1
    return "查找失败, 元素{}不存在".format(target)


if __name__ == '__main__':
    # 有序列表
    data_list = [1, 5, 9, 11, 23, 36, 47, 59, 61, 70, 85, 99, 100]
    print(binary_search(data_list, 47))
    print(binary_search(data_list, 111))

